package api

import (
	"go-middle/library/response"
	"go-middle/library/token"

	"github.com/gogf/gf/frame/g"
	"github.com/gogf/gf/net/ghttp"
	"github.com/gogf/gf/os/glog"
)

// Token    获取token
// @Tags    登录
// @Summary 获取token
// @Accept  multipart/form-data
// @Produce  json
// @Success 200 {object} response.JsonResponse "code 0成功1失败"
// @Router /api/token [get]
func Token(r *ghttp.Request) {
	tokens, err := token.Generate()
	if err != nil {
		glog.Error(err)
		response.Error(r, "token生成失败", nil)
	}
	response.Success(r, "success", g.Map{"token": tokens.Token})
}
